package com.snj.bestdealer.news;

import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.Log;

import com.snj.bestdealer.lib.CustomHttpClient;
import com.snj.bestdealer.lib.Global;

public class NewsItem {
	
	
	String no = null;
	String title = null;
	String content = null;
	String coversrc = "";
	Bitmap cover = null;
	String imgsrc = "";
	Bitmap img = null;
		
	public NewsItem(String _no, String _title, String _content, String _imgsrc, String _coversrc)
	{
		// TODO Auto-generated constructor stub
		
		this.no = _no;
		this.title = _title;
		this.content = _content;
		this.imgsrc = _imgsrc;
		this.coversrc = _coversrc;
		
		new AsyncTask<String, Bitmap, String>() {
					
			

			@Override
			protected void onPreExecute() {
				// TODO Auto-generated method stub
				super.onPreExecute();
				
				
				Log.d("News", "PreExecute");
			}

			@Override
			protected String doInBackground(String... params) {
				// TODO Auto-generated method stub
				
				
				
				
				Log.d("News", "Start load");
				img = CustomHttpClient.downloadBitmap(params[0]);
				//img = BitmapFactory.decodeFile(savedpath); 
				cover = CustomHttpClient.downloadBitmap(params[1]);
				
				return null;
			}
			
			
		}.execute(imgsrc, coversrc, no);
		
	}
	
	public NewsItem(String _no, String _title, String _content, String _imgsrc, Bitmap _img, Bitmap _cover)
	{
		// TODO Auto-generated constructor stub
		
		this.no = _no;
		this.title = _title;
		this.content = _content;
		this.imgsrc = _imgsrc;
		this.cover = _cover;
		this.img = _img;
	}
	
	public Bitmap GetImage()
	{
		return this.img;
	}	
	
	public String GetImgSrc()
	{
		return this.imgsrc;
	}
	
	public Bitmap GetCover()
	{
		return this.cover;
	}	
	
	public String GetNo()
	{
		return this.no;
	}
	
	public String GetTitle()
	{
		return this.title;
	}
	
	public String GetContent()
	{
		return this.content;
	}
}
